Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstring, variable name, formatting updates to IDEX L1 #799

Merged

Conversation

bourque
Copy link
Collaborator

@bourque bourque commented Aug 29, 2024

This PR includes various updates to docstrings, variable names, code organization, etc. to just make things a bit more readable and consistent in the IDEX L1 code (in my opinion!)

@bourque bourque added Ins: IDEX Related to the IDEX instrument Level: L1 Level 1 processing labels Aug 29, 2024
@bourque bourque self-assigned this Aug 29, 2024
Comment on lines +28 to +37
# Create a large dictionary of values from the FPGA header that need to be
# captured into the CDF file. They are lumped together because they share
# similar attributes.
# Notes about the variables are set here, acting as comments and will also be
# placed into the CDF in the VAR_NOTES attribute.
TRIGGER_DESCRIPTION = namedtuple(
"TRIGGER_DESCRIPTION",
["name", "packet_name"],
)
TRIGGER_DESCRIPTION_DICT = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to the top of the file and made them ALL_CAPS since they are treated as global variables

Copy link
Contributor

@tech3371 tech3371 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines 13 to 25
@pytest.fixture(scope="session")
def decom_test_data():
def decom_test_data() -> xr.Dataset:
"""Return a ``xarray`` dataset containing test data.

Returns
-------
dataset : xarray.Dataset
A ``xarray`` dataset containing the test data
"""
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts"
)
return PacketParser(test_file, "001")
return PacketParser(test_file, "001").data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of us have moved function that's shared across tests into tests/<instrument>/conftest.py. Can you do similar here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea!

} # fmt: skip


def get_idex_attrs(data_version: str) -> ImapCdfAttributes:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this function to below all of the Class definitions

@@ -123,34 +104,30 @@ class PacketParser:
data_version : str
The version of the data product being created.

Methods
-------
TODO : Add method to generate quicklook plots
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this TODO to the top of the file

_calc_high_sample_resolution(num_samples)
parse_packet(packet)
Calculate the resolution of high samples.
_populate_bit_strings(packet)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed parse_packet to _populate_bit_strings to be more explicit about what the method is doing. Also the words "parse" and "packet" are used a lot elsewhere so it could get confusing.

Comment on lines 13 to 25
@pytest.fixture(scope="session")
def decom_test_data():
def decom_test_data() -> xr.Dataset:
"""Return a ``xarray`` dataset containing test data.

Returns
-------
dataset : xarray.Dataset
A ``xarray`` dataset containing the test data
"""
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts"
)
return PacketParser(test_file, "001")
return PacketParser(test_file, "001").data
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea!

@bourque bourque merged commit 1efc197 into IMAP-Science-Operations-Center:dev Sep 3, 2024
17 checks passed
@bourque bourque deleted the idex-l1-small-updates branch September 3, 2024 21:54
laspsandoval pushed a commit to laspsandoval/imap_processing that referenced this pull request Sep 4, 2024
…-Operations-Center#799)

* Various updates to docstrings, variable names, formatting
* Moved pytest fixture that returns test data to conftest.py
@bourque bourque added this to the Sept 2024 milestone Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: IDEX Related to the IDEX instrument Level: L1 Level 1 processing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants